package com.example.controller;

import com.example.common.Result;
import com.example.enums.ResultCodeEnum;
import com.example.pojo.Emp;
import com.example.pojo.LoginInfo;
import com.example.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @PostMapping()
    public Result login(@RequestBody Emp emp){
        LoginInfo loginInfo = loginService.login(emp);
        if(loginInfo != null){

            return Result.success(loginInfo);
        }
        return Result.error("账号或密码错误");
    }
}
